﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace P2PFileScheduling
{
    class Program
    {
        static void Main(string[] args)
        {
            Test1();

            //Digraph graph = new Digraph("input1.txt");
            //Console.WriteLine(graph.toString());

            //Console.WriteLine(FlowCalc.FordFulkerson(graph, 1));
            //BreadthFirstDirectedPaths BFS = new BreadthFirstDirectedPaths(graph, graph.superSource.number,1);
            //List<DirectedEdge> P = BFS.getCut();

            //foreach (DirectedEdge e in P)
            //{
            //    Console.WriteLine("fra " + e.from().number + " til " + e.to().number+" flow: "+e.flow);
            //}

            //Console.ReadKey();
        }

        /// <summary>
        /// Runs a simple test of the algorithm on "input_single_fp" (single-commodity)
        /// </summary>
        static void Test1()
        {
            Digraph graph = new Digraph("input_single_fp.txt");
            //int innerTimeSteps = 0;
            int outerTimeSteps = 0;

            while (!graph.IsDone())
            {
                int type;
                for (type = 0; type < graph.NumFilePieces; ++type)
                {
                    int flow = FlowCalc.FordFulkerson(graph, type);
                }

                //Console.WriteLine("Used {0} inner time steps to distribute file piece {1}", innerTimeSteps, type);
                //innerTimeSteps = 0;
                ++outerTimeSteps;
            }

            Console.WriteLine("All {0} file piece(s) were distributed in {1} time steps", graph.NumFilePieces, outerTimeSteps);
        }

        static void Test2()
        {
            bool[] arr1 = { true, false, true };
            bool[] arr2 = { true, true, true };
            Func<bool, bool> predicate = x => x == true;

            Console.WriteLine(arr1.All(predicate));
            Console.WriteLine(arr2.All(predicate));
        }
    }
}
